import { ref } from 'vue'
import { defineStore } from 'pinia'
import { useUserInfoStore } from './userInfoStore'
import { usePlayListStore } from './playListStore'

export const useCookieStore = defineStore('cookie', () => {
  const useUserInfo = useUserInfoStore()
  const usePlayList = usePlayListStore()
  
  const cookie = ref({})

  // 清空 cookie
  const clearCookie = () => {
    cookie.value = {}
  }

  // 退出登录
  const logout = () => {
    clearCookie()
    useUserInfo.clearUesrInfo()
    usePlayList.clearPlayList()
  }

  return {
    cookie,
    clearCookie,
    logout
  }

}, {
  persist: true
})
